package servlet;


import service.impl.ProdutcServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author admin
 * @Date 2019/2/28 8:14
 */
@WebServlet(name = "DelServlet",urlPatterns = "/delServlet")
public class DelServlet extends HttpServlet {
    ProdutcServiceImpl service = new ProdutcServiceImpl();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pid = request.getParameter("pid");
        int i = service.deleteProduct(Integer.parseInt(pid));
        if (i > 0){
            System.out.println("删除成功");
        }
        request.getRequestDispatcher("findAll").forward(request,response);

    }
}
